﻿using Autofac;
using CleanArchitecture.Core.Configuration;
using CleanArchitecture.Core.Interfaces;
using CleanArchitecture.Core.Interfaces.DependencyManagement;
using CleanArchitecture.Infrastructure.Interfaces.Business;
using CleanArchitecture.Infrastructure.Interfaces.Customers;
using CleanArchitecture.Infrastructure.Services.Business;
using CleanArchitecture.Infrastructure.Services.Customers;
using CleanArchitecture.Web.Factories;
using CleanArchitecture.Web.MvcRouteConfig;

namespace CleanArchitecture.Web.Dependency
{
    /// <summary>
    /// 与网站业务相关的Service/Interface注册在此完成
    /// </summary>
    public class WebBusinessDependency : IDependencyRegistrar
    {
        public int Order => 2;
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NowaConfig config)
        {
            builder.RegisterType<FrontRouteTransformer>().AsSelf().InstancePerLifetimeScope();
            //Services
            builder.RegisterType<NewsService>().As<INewsService>().InstancePerLifetimeScope();
            builder.RegisterType<BlogService>().As<IBlogService>().InstancePerLifetimeScope();
            builder.RegisterType<ColumnService>().As<IColumnService>().InstancePerLifetimeScope();
            builder.RegisterType<LanguageService>().As<ILanguageService>().InstancePerLifetimeScope();
            builder.RegisterType<AdvertiseService>().As<IAdvertiseService>().InstancePerLifetimeScope();
            builder.RegisterType<CommentService>().As<ICommentService>().InstancePerLifetimeScope();
            builder.RegisterType<CustomerService>().As<ICustomerService>().InstancePerLifetimeScope();
            builder.RegisterType<CustomerRegistrationService>().As<ICustomerRegistrationService>().InstancePerLifetimeScope();

            builder.RegisterType<ActiveLogService>().As<IActiveLogService>().InstancePerLifetimeScope();

            //Factories
            builder.RegisterType<AdminUserModelFactory>().As<IAdminUserModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType<SystemManageModelFactory>().As<ISystemManageModelFactory>().InstancePerLifetimeScope();
            
            builder.RegisterType<BusinessModelFactory>().As<IBusinessModelFactory>().InstancePerLifetimeScope();
            

        }
    }
}
